(function() {
	"use strict";

	// 有序 Map
	var Map = function() {
		this.data = new Array();

		this.push = function(key, value) {
			this.data.push({
				key: key,
				value: value
			})
		};
		
		this.toArray = function() {
			return this.data;
		};
		
		this.toObject = function() {
			var map = {};
			for(var key in this.data) {
				var obj = this.data[key];
				map[obj.key] = obj.value;
			}
			return map;
		};

		this.test = function() {};
	};

	// todo 自动排序
	Map.getMapBySort = function(obj) {

		var keyArray = [];
		for(var key in obj) {
			keyArray.push(key);
		}
		keyArray.sort();

		var map = new Map();

		for (var i = 0; i < keyArray.length; i++) {
			var key = keyArray[i];
			var value = obj[key];
			if(value != null) {
				map.push(key, value);
			}
		}

		return map;
	};

	window.Map = Map;

}());